package com.fs.controller;


import com.fs.pojo.Sys_menu;
import com.fs.service.MenuService;
import com.fs.vo.Meta;
import com.fs.vo.ResponseData;
import com.fs.vo.RouterVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/getRouters")
public class LoginController {

    @Resource
    private MenuService menuService;

    @GetMapping
    public ResponseData<List<RouterVo>> getMenuList(){
        ResponseData<List<RouterVo>> responseData = new ResponseData<>();
        List<Sys_menu> sysmenuList = menuService.getMenuList();
        if (sysmenuList != null){
            responseData.setData(menuService.buildMenus(sysmenuList));
            Meta meta = new Meta(200,"操作成功");
            responseData.setMeta(meta);
        }else {
            Meta meta = new Meta(404,"数据库中未找到菜单列表");
            responseData.setMeta(meta);
        }
        return responseData;
    }
}
